package com.eonmind.vip.mapper;

import com.eonmind.common.contract.data.base.BaseMongoMapper;
import com.eonmind.common.provider.entity.vip.VipPackage;
import com.mongoplus.conditions.update.UpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class VipPackageMapper extends BaseMongoMapper<VipPackage> {
    public List<VipPackage> getPlanByIds(List<Long> ids) {
        return getByIds(ids);
    }

    public void updateSales(Long id, Integer num) {
        UpdateWrapper<VipPackage> updateWrapper = createMgoUpdate().eq(VipPackage::getId, id)
                .inc(VipPackage::getSales, num);
        update(updateWrapper);
    }

}
